﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using School.Entities;
using System.Drawing;

namespace School.Pages.Teaching
{
    public partial class TE_Student_Topic : System.Web.UI.Page
    {
        public string stud_Id = "31";
        private static SchoolEntities db = new SchoolEntities();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlBind(ddlSubjects, School.Teaching.Teaching.Get_Subject_ByStud_id(31));
            }
            //if (ddlTopic.SelectedIndex > 0)
            //    gvBank_QinBind();

        }
        protected void ddlSubjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlSubjects.SelectedIndex > 0)
            {
                ddlBind(ddlCourse, School.Teaching.Teaching.Get_Course_By_Subject(Convert.ToInt32(ddlSubjects.SelectedValue)));
            }
        }
        private void ddlBind(DropDownList ddl, object o)
        {
            ddl.DataSource = o;
            ddl.Items.Clear();
            ddl.Items.Insert(0, new ListItem("اختيار", "0"));
            ddl.DataBind();
        }

        private void gvBank_QinBind()
        {
            gvBank_Qin.DataSource = School.Teaching.Teaching.Get_Topic_Q_inAnswer(Convert.ToInt32(ddlCourse.SelectedValue));
            gvBank_Qin.DataBind();
        }


        protected void gvBank_Qin_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvBank_Qin.PageIndex = e.NewPageIndex;
            gvBank_QinBind();
        }


        public string addType(object url)
        {
            return url.ToString().Replace("?", "?Stud_id=" + stud_Id.ToString() + "&");
        }

        protected void btnsearch_Click(object sender, EventArgs e)
        {
            if (ddlCourse.SelectedIndex > 0)
            {
                gvBank_QinBind();
            }
        }


    }
}